home *** CD-ROM | disk | FTP | other *** search
- /*
- this small programm should clear the communication line specified
- It uses the UNIX fork() system call to avaoid stuck on read.
- Thus, this program is NOT AVAILABLE AT THE AMIGA at the time.
- */
-
- #include <stdio.h>
- #include <sys/types.h>
- #include <signal.h>
- #include <strings.h>
- #include <auxcfg.h>
-
- #define FLAGFILE /tmp/devclr.flg
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- int i,n,m,fd,pid;
- char c,s[80],z[80],a[80];
-
- if(argc!=2) {
- printf("This program should be used to clear communication lines to\n");
- printf("auxillary devices. You must specify the device entry for\n");
- printf("the Aux_Config file.\n");
- printf("To avoid printing of all character from the line to your\n");
- printf("terminal, redirection to /dev/null is recommended\n");
- exit(-1);
- }
- fd=auxopen(argv[1]);
- printf("reading from line %s\n",auxparams[0]);
-
- pid=fork();
- if(pid==0) { /* child process reads the line */
- while(1==1) {
- read(fd,&c,1);
- printf("%c",c); fflush(stdout);
- }
- } else { /* here we have the parent process, which essentially sleeps */
- sleep(2);
- n=kill(pid,SIGKILL); /* we should get rid of our child now */
- }
- }
-